package cn.sczhyt.modules.szhy.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import cn.sczhyt.modules.szhy.service.MeetingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import cn.sczhyt.modules.szhy.entity.MeetingHotelEntity;
import cn.sczhyt.modules.szhy.service.MeetingHotelService;
import cn.sczhyt.common.utils.PageUtils;
import cn.sczhyt.common.utils.R;



/**
 * 会议酒店住宿安排
 *
 * @author luojialin
 * @email 78357966@qq.com
 * @date 2021-03-25 10:02:00
 */
@Api(tags = "PC端住宿安排")
@RestController
@RequestMapping("szhy/meetinghotel")
public class MeetingHotelController {
    @Autowired
    private MeetingHotelService meetingHotelService;
    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = meetingHotelService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @ApiOperation("会议住宿安排列表")
    @GetMapping("/info/{meetingId}")
    public R info(@PathVariable("meetingId") String meetingId){

		List<MeetingHotelEntity> list = meetingHotelService.getByMeetingId(meetingId);

        return R.ok().put("data", list);
    }

    /**
     * 保存
     */
    @ApiOperation("新增住宿安排")
    @PutMapping("/save")
    public R save(@RequestBody MeetingHotelEntity meetingHotel){

        System.out.println("MeetingHotelController.save" + meetingHotel);

		meetingHotelService.saveMeetingHotel(meetingHotel);

        return R.ok();
    }

    /**
     * 修改
     */
    @ApiOperation("修改住宿安排")
    @PostMapping("/update")
    public R update(@RequestBody MeetingHotelEntity meetingHotel){

		meetingHotelService.updateById(meetingHotel);

        return R.ok();
    }

    /**
     * 删除
     */
    @ApiOperation("删除住宿安排")
    @DeleteMapping("/delete")
    public R delete(@RequestBody String[] hotelIds){
		meetingHotelService.removeByIds(Arrays.asList(hotelIds));

        return R.ok();
    }

}
